using UnityEngine;
using System.Collections;

public class GuiMouseCursor : MonoBehaviour {
	const int GUI_DEPTH = 0;
	Texture2D cursor = null;
	
	// Use this for initialization
	void Start () {
	
	}
	
	public void SetCursor(Texture2D cursor_icon) {
		this.cursor = cursor_icon;
	}
	
	public void UnsetCursor() {
		this.cursor = null;
	}
	
	bool IsCursorVisible() {
		return (this.cursor != null);
	}
	
	// Update is called once per frame
	void OnGUI () {
		Vector3 mouse_pos;
		Vector2 gui_pos;
		
		if (!this.IsCursorVisible()) {
			return;
		}
		
		/* mouse cursor needs to be on top of everything */
		GUI.depth = GuiMouseCursor.GUI_DEPTH;
			
		mouse_pos = Input.mousePosition;
		
		gui_pos = GuiIO.MousePosToGuiPos(mouse_pos);
		GUI.Label (new Rect(
			gui_pos.x, gui_pos.y,
			this.cursor.width,
			this.cursor.height),
			this.cursor);
		
	}
}
